package com.umakr.ax.app.service;

import com.baomidou.mybatisplus.plugins.Page;
import com.google.common.collect.Maps;
import com.umakr.ax.common.mapper.RadioStationFollowerMapper;
import com.umakr.ax.common.model.RadioStationFollower;
import com.umakr.ax.common.service.AttentionService;
import com.umakr.ax.common.service.RadioStationFollowerService;
import com.umakr.ax.common.vo.RadioStationFollowerVO;
import com.umakr.ax.core.base.BaseService;
import com.umakr.ax.utils.FormatPhotoUrlUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;

import java.util.Map;
@Service
public class RadioStationFollowerWebService extends BaseService<RadioStationFollowerMapper, RadioStationFollower> {
    @Autowired
    RadioStationFollowerService radioStationFollowerService;
    @Autowired
    AttentionService attentionService;

    @Autowired
    Environment env;

    public Object listFollowers(Long rsId,String nickName) {
        String aliUrl = env.getProperty("oss.img.path");
        String defaultAvatar = env.getProperty("user.default.avatar");
        Page<RadioStationFollowerVO> page = baseMapper.listFollowers(rsId,nickName);
        for (RadioStationFollowerVO item : page.getRecords()){
            //设置链接地址
            item.setHeadImgUrl(item.getHeadImgUrl() == null ?  aliUrl+defaultAvatar : FormatPhotoUrlUtil.formatString(aliUrl,item.getHeadImgUrl()));
        }
        return page;
    }

    public Object delFollowers(String ids) {
        return radioStationFollowerService.delFollowers(ids);
    }


}
